package writeor.aidraw.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import writeor.aidraw.dao.AiImageDao;
import writeor.aidraw.model.AiImages;
import writeor.aidraw.model.User;
import writeor.aidraw.service.AiImageService;

import java.util.List;


/**
 * 商品分类管理
 */
@Service("AiImageService")
@Transactional
public class AiImageServiceImpl implements AiImageService {
    @Autowired
    private AiImageDao aiImageDao;

    @Override
    public int give_like(String img_path,int like) {
        return aiImageDao.give_like(img_path,like);
    }

    @Override//显示用户自己的图片并且查询
    public PageInfo<AiImages> SearchImageWithUser(Integer page, Integer count, String find_images, String user_name) {
        System.out.println("SearchImageWithUser"+find_images+user_name);
        PageHelper.startPage(page,count);
        List<AiImages> list=aiImageDao.SearchAiImageWithUser(find_images,user_name);
        PageInfo<AiImages> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override//显示用户自己的图片
    public PageInfo<AiImages> FindImageListWithUser(Integer page, Integer count, String user) {
        PageHelper.startPage(page,count);
        List<AiImages> list=aiImageDao.selectAiImageWithUser(user);
        PageInfo<AiImages> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public PageInfo<AiImages> FindImageListForPage(Integer page, Integer count) {
        PageHelper.startPage(page,count);
        List<AiImages> list=aiImageDao.selectAiImageWithPage();
        PageInfo<AiImages> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int updateImage108(AiImages aiImages) {
        System.out.println("======修改图片为==="+aiImages);
        return aiImageDao.updateImage108(aiImages);
    }

    @Override
    public int deleteImage108(String img_path) {
        return aiImageDao.deleteImage108(img_path);

    }

    @Override
    public PageInfo<AiImages> FindImageByPrompt(Integer page, Integer count, String find_images) {
        PageHelper.startPage(page,count);
        List<AiImages> images= aiImageDao.FindImageByPrompt(find_images);
        PageInfo<AiImages> pageInfo=new PageInfo<>(images);
        return pageInfo;
    }


}
